import {nextTick} from "../../lib/utils.js";
import { asyncSetInterval } from "../../lib/zeroReportUtils.js";

/**
 * Created by tangqiaojie <2482366539@qq.com> on 2020/7/6 0006
 */
const handleSmallStep1=()=>{
  asyncSetInterval(()=>{
    let msgBox = $(".mini-messagebox");
    let tips = "系统检测到您上次填写了申报表";
    if (msgBox.find(".mini-messagebox-content").text().includes(tips)) {
      msgBox.find(".mini-button:eq(1)")[0].click();
    }
    return true;
  },1000).then(()=>{
    setTimeout(()=>{
      let tabs=$(".mini-tab");
      tabs.each((index,item)=>{
        setTimeout(()=>{
          $(item.click());
        },index*1000)
      });
      nextTick(()=>{
        console.log($("#sb_save"));
        if($("#sb_save").length){
          window.localStorage.setItem("zzsReady",1);
          $("#sb_save").click();
          nextTick(()=>{
            let btn=$(".mini-panel-border .mini-button:eq(0)");
            if(btn.length && btn.html().includes("确定")){
              btn.click();
              nextTick(()=>{
                let btn=$(".mini-panel-border .mini-button:eq(0)");
                if(btn.length && btn.html().includes("确定")){
                  btn.click();
                  return true;
                }
              },500);
              return true;
            }
          },500);
          return true;
        }
      },4000)
    },2000)
  })
 
}

const handleSmallStep2=()=>{
  // window.close();
}

export {
  handleSmallStep1,
  handleSmallStep2,
};
